package org.netty.mvc.controller;

import com.alibaba.fastjson.JSONObject;
import io.netty.handler.codec.http.HttpRequest;
import org.netty.mvc.annotation.*;

import java.util.LinkedList;
import java.util.List;

/**
 * 测试使用
 *
 * @Author Jun jie Yi
 * @Date 2022/3/8 12:17
 */
@NettyController
@NettyRequestMapping(value = "user")
public class ControllerTest {

    @NettyRequestMapping(value = "aaa", method = RequestMethod.GET)
    public User test1() {
        User user = new User("aaaa", 12);
        return user;
    }

    @NettyRequestMapping(value = "/bbb", method = RequestMethod.POST)
    public Object test2(@RequestBody JSONObject jsonObject, HttpRequest request) {
        System.out.println(jsonObject);
        System.out.println(request.uri());
        return "SUCCESS";
    }

    @NettyRequestMapping(value = "/ccc", method = RequestMethod.POST)
    public Object test3(@RequestBody JSONObject jsonObject) {
        List<User> list = new LinkedList<>();
        list.add(new User("aaa", 1));
        list.add(new User("bbb", 2));
        list.add(new User("ccc", 3));
        list.add(new User("ddd", 4));
        return list;
    }

    @NettyRequestMapping(value = "ddd", method = RequestMethod.GET)
    public String test4(@RequestParam("param1") String param1) {
        System.out.println(param1);
        return param1;
    }
}
